<%--
  Created by IntelliJ IDEA.
  User: WY2015092804
  Date: 2015/10/12
  Time: 16:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="st" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="j" uri="j/tags" %>
<%@ taglib prefix="easyui" uri="http://www.joyi.cn/easyui/tags" %>
<st:page title="城市">
    <div data-options="region:'west',title:'用户分类管理',split:true" style="width:260px;">
        <table id="tt" class="easyui-treegrid"
               data-options="toolbar:'#addToolbar',fit:true,url:'/user/req?rid=<j:des data="20151012000000000003"/>',idField:'cityId',treeField:'cityName'">
            <thead>
            <tr>
                <th data-options="field:'cityId',formatter:onFormatter">操作</th>
                <th data-options="field:'cityName'">地区</th>
            </tr>
            </thead>
            <div id="#addToolbar">
                <easyui:linkButton name="新增地区" iconKey="add" onClick="addCity()"></easyui:linkButton>
            </div>
        </table>
    </div>
    <div data-options="region:'center',title:'用户管理'" style="padding:5px;background:#f00;">
    </div>
    <script>

        function onFormatter(value, rowData, index) {
            var ht = "";
            ht += "<a href='javascript:void(0);' onclick='edit(\"" + value + "\")'>修改</a>";

            ht += "<a href='javascript:void(0);' onclick=\"del('" + value + "')\">删除</a>";

            return ht;
        }


        /**
         * 添加
         */
        function addCity() {
            j.open("/user/pd?act=jsp&jsp=<j:des data="city/editCity"/>", "addCity", {title: "添加地区信息"}, 500, 400);
        }
        function edit(id) {
            j.open("/user/req?rid=<j:des data="20151014000000000006"/>&id=" + id, "editCity", {title: "修改地区信息"}, 500, 400);
        }
        function reloadCityTreegrid() {
            $("#tt").treegrid("reload");
        }
        function del(cityId) {
            if (window.confirm("确定删除此地区么？")) {
                Http.post("/user/req?rid=<j:des data="20151014000000000001"/>", {id: cityId}, function (da) {
                    alert(da.data["da"]);
                    reloadCityTreegrid();

                });

            }
        }


    </script>
</st:page>
